package com.company;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author jrue
 * @version 1.0
 * @date 2020/3/25 14:18
 */
// 字典树
public  class MyTreeNode {

    Character val;
    HashMap<Character,MyTreeNode> children = new HashMap<>();
    void insert(String word, MyTreeNode root) {
        char[] chars = word.toCharArray();
        MyTreeNode p = root;
        for (int i = 0; i < chars.length; i++) {
            HashMap<Character, MyTreeNode> children = p.children;
            if (children.containsKey(chars[i])) {
                p = children.get(chars[i]);
            } else {
                MyTreeNode node = new MyTreeNode();
                node.val = chars[i];
                children.put(chars[i],node);
                p = node;
            }
        }
    }

    public static void main(String[] args) {
        MyTreeNode root = new MyTreeNode();
        root.insert("abc",root);
        root.insert("abd",root);
        System.out.println("hello");
    }

}


